package com.student.service;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;

import com.student.DBConn;
import com.student.entities.SellerEntity;

public class SellerService {
	public static List<SellerEntity> getAllSeller() throws SQLException {
		List<SellerEntity> sellerList = new ArrayList<SellerEntity>();
		Connection conn = DBConn.getConn();
		Statement stmt = conn.createStatement();
		String sql = "select * from shop_seller where seller_isVerify = 1";

		ResultSet rs = stmt.executeQuery(sql);

		// List<Map<String, String>> sellerList = new ArrayList<Map<String,
		// String>>();
		while (rs.next()) {
			// System.out.println(rs.getString(1));
			SellerEntity seller = new SellerEntity();
			seller.setId(rs.getInt("seller_id"));
			seller.setName(rs.getString("seller_name"));
			seller.setLogoURL(rs.getString("seller_logo"));
			seller.setAddress(rs.getString("seller_addr"));
			seller.setTel(rs.getString("seller_tel"));
			seller.setDeliverTime(rs.getString("seller_deliverTime"));
			sellerList.add(seller);
		}
		rs.close();
		stmt.close();
		conn.close();
		return sellerList;
	}
}
